In order to get trace information from a program for specific method calls, a user defines a selection of methods to be traced. However, if the user wants to trace the call tree of a particular method (that is, all the “branch” & “leaf” methods called by a method of interest), there is currently no easy way to do this.
One current approach is to identify all the branch and leaf methods under the method of interest. Then, set options so as to trace all of these branch and leaf methods. This will result in a trace generated for all the hits of the branch and leaf methods. Depending on the frequency of usage of these methods in the system, most of the hits might not be associated with the method of interest. This will result in a huge amount of trace data, which needs to be filtered in order to get meaningful and/or useful data.
Consider the pseudo-code implementation of a “foo” routine 1100, as depicted in FIG. 2. In order to trace all methods called by foo, enable method tracing of methods foo( ) 1102, bar( ) 1104, hello( ) 1106, world( ) 1108, print( ) 1110, malloc( ) 1112, strlen( ) 1114, and free( ) 1116; for example, by specifying a trace option such as: trace_methods=foo:malloc:strle:free:bar:hello:world:print. Once this method tracing is enabled, all the required trace information will be obtained. However, there will be several irrelevant trace hits for malloc( ), strlen( ), and free( ), depending on the usage of these functions in the software of which foo( ) is a part. Thus, in the current technique, once a method is specified, it will be traced no matter in what context it is called, and no matter what other method calls the specified method.
Accordingly, it will be necessary to process the resultant trace data to filter the unimportant trace hits. Furthermore, this requires understanding of, and source access to, foo( ) and other methods involved, so as to specify all the methods it calls, as they need to be manually specified as trace options.
Note that in some current techniques, an agent performs byte code modification to update code of the methods (which need to be selected by specifying the package to trace, and so on) to include method entry and exit points. A trace is generated for all the invocations of these methods, no matter which routine is calling these methods. This trace is collected and post-processed (filtering out any invocations which are not part of a required call tree) to build call tree information and display it in a required format.